<?php
/**
 * Created by PhpStorm.
 * User: mazhangyi
 * Date: 2020/1/8
 * Time: 18:56
 */

namespace app\api\model\v1;
use think\Controller;
use think\Db;
use think\Request;
use app\api\model\v1\User2 as userModel2;

class Register
{
  static function register($params){
      $user = User2::create($params,true);
      $user->save();
      //返回的数字大于0 代表插入成功;
      return $user->UID;
  }

  static function registerCheck($params){
        //校验用户名唯一性;
      return Db::table('jg_users')->where('USERNAME',$params)->select();
   }

   //插入待激活的数据表;
   static function registerCode($uid){
      $params = [
          //生成一个激活码;
          'CODE'=>md5('WT18'.md5(time()).mt_rand(10000,99999)),
          //获取最新的uid
          'UID'=>$uid,
          'STATUS'=>0,
      ];
//       Db::table('jg_users_code')->insert($params);

       return Db::table('jg_users_code')->insert($params);
//          'CREATE_TIME'=>date('Y-m-d H:i:s',time() + 7*24*60*60);

//      return $params['CODE'];
   }
}